import { createApp } from 'vue'
import App from './App.vue'
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import * as farmeWork from '@common/src/utils/index'
import * as VueRouter from 'vue-router'
import { RouteRecordRaw } from 'vue-router'
import type { farmeWorkType } from '@common/src/interface/utils'
import { loadVxeTable } from '@common/src/utils/vxeTable.ts'

farmeWork.default().then((res: farmeWorkType) => {
    const app = createApp(App)
    app.config.globalProperties.$farmeWork = res
    const routers: Array<RouteRecordRaw> = res.router
    const componentsList = res.components
    const router = VueRouter.createRouter({
        // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
        history: VueRouter.createWebHashHistory(),
        routes: routers
    })

    const globalConfig = reactive({
        size: 'small'
    });
    app.use(router)
    app.use(componentsList)
    app.use(res.resizable)
    app.use(ElementPlus, globalConfig)
    app.use(loadVxeTable)
    app.provide('globalConfig', globalConfig)
    app.mount('#app')
})


